import commonjs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
import babel from '@rollup/plugin-babel'
import pkg from '../package.json'

const path = require('path')

const extensions = ['.js', '.jsx', '.ts', '.tsx']

// Base Plugins
const plugins = [
  // Allows node_modules resolution
  resolve({ extensions }),
  // Allow bundling cjs modules. Rollup doesn't understand cjs
  commonjs(),
  // Compile TypeScript/JavaScript files
  babel({
    extensions,
    exclude: "node_modules/**", // 只编译我们的源码
    // runtimeHelpers: true,
  }),
]

const appConfig = {
  // input: "../src/example/app.ts",
  input: path.resolve(__dirname, '../src/index.ts'),
  plugins,
  output: [
    {
      file: pkg.main,
      format: "umd",
      name: 'logUtils'
    },
    {
      file: pkg.module,
      format: "es",
    },
  ]
}

export default [appConfig]